﻿#ifndef MSGPROCESS_H
#define MSGPROCESS_H
#include<QThread>
#include "globalvars.h"
#include "execsql.h"

class MsgProcess : public QThread
{
    Q_OBJECT
signals:
    void signalUploadPicSuccessed();
    void signalSendMsgToClient(QString id, QString msg);
    void signalSendImageToClient(QString id, QString msg,QString path);
    void signalShowImage(QImage image);
    void signalSaveHouseImage(const QString&,const QImage& image);
    void signalSaveHotelImage(const QString&,const QImage& image);
    void signalSaveCommentImage(const QString&,const QImage& image);
    void signalSaveUserCertImage(const QString&,const QImage& image);
    void signalSaveUserHeadImage(const QString&,const QImage& image);

public:
    explicit MsgProcess(QThread *parent = nullptr);
    void exitThread(void);

protected:
    void run();

private:
    bool m_isExit;
    QStringList m_pathList;

    int m_userInedx;
    int m_userImageInedx;
    int m_userImageCount;
    int m_reserveInedx;
    int m_sendImageIndex;
    int m_saveInedx;
    int m_commentInedx;
    int m_houseInedx;
    int m_hotelInedx;
    int m_houseImageInedx;
    int m_hotelImageInedx;
    int m_hotelImageCount;
    int m_commentImageInedx;
    int m_commentImageCount;

    int m_hotelManageIndex;

    void parseUserAsk(QString msg);
    ///解析用户信息请求命令 - 登录退出在MsgSocket中实现
    void parseUserRegister(QString data);
    void parseUserInfos(QString data);
    void parseHeadPic(QString msg);
    void parseModifyPassword(QString msg);
    void parseModifyUserInfos(QString msg);
    void SendHotelInfoListOneByOne(QString userID);

    ///解析酒店请求命令
    void parseGainHotelInfoList(QString data);
    void parseHotelImage(QString cmd,QString msg);
    void parseHotelDetailImage(QString msg);
    void parseHotelDetails(QString msg);
    void SendHouseListOneByOne(QString msg);

    ///解析房间请求命令
    void parseGetHouseList(QString msg);
    void parseHouseImage(QString userID);

    ///解析订单请求命令
    void parseReserveSubmit(QString data);
    void parseGainReserveList(QString data);
    void SendReserveListOneByOne(QString data);
    void parseReserveHotelImage(QString data);
    void SendReserveImageListOneByOne(QString data);
    void parseGainReserveDetails(QString data);
    void parseReserveDelete(QString data);

    ///解析评论请求命令
    void parseCommentSubmit(QString data);
    void parseGainCommentList(QString data);
    void SendCommentListOneByOne(QString data);
    void parseGainCommentImage(QString data);
    void SendCommentImageOneByOne(QString data);

    ///解析收藏请求命令
    void parseGainSaveList(QString data);
    void SendSaveListOneByOne(QString data);
    void parseSaveHotelImage(QString data);
    void SendSaveImageListOneByOne(QString data);
    void parseGainHotelDetailsByID(QString data);
    void parseDeleteSave(QString msg);
    void parseSubmitSave(QString msg);

    ///解析上传的图片命令
    void parseUserAsk(ImageMsgMap msg);
    void parseUploadHeadPic(const QString& msg, const QImage& image);
    void parseBusinessManCertificate(const QString &msg, const QImage& image);
    void parseSubmitCommentImage(const QString &msg, const QImage& image);


    /////////////////////////////////////business////////////////////////////////////////
    void parseGainHotelManageIdAndName(QString msg);
    void parseGainHotelManageList(QString msg);
    void sendHotelManageListOneByOne(QString& userID);
    void parseHotelManageImage(QString msg);
    void SendHotelManageImageOneByOne(QString& userID);
    void parseDeleteHotel(QString msg);
    void parseDeleteHouse(QString msg);
    void parseSubmitHotel(QString msg);
    void parseSubmitHouse(QString msg);
    /// 上传图片
    void parseSubmitHouseImage(const QString msg, const QImage& image);
    void parseSubmitHotelImage(const QString msg, const QImage& image);

    void parseGainOrderManageList(QString msg);
    void sendOrderManageListOneByOne(QString& userID);
    void parseModifyOrderState(QString msg);
    void parseSubmitBusComment(QString msg);


    /////////////////////////////////////worker////////////////////////////////////////
    void parseGainUserCertList(QString msg);
    void sendUserCertListOneByOne(QString& msg);
    void parseHotelCertResult(QString msg);
    void parseGainUserCertImage(QString msg);
    void sendUserCertImageOneByOne(QString& msg);
    void parseUserCertResult(QString msg);
};

#endif // MSGPROCESS_H
